/**
 * 作者: wgx
 * 日期: 2024-09-30 11:30:00
 * 备注: 用户扩展信息表（字段不能设置默认值，代码里设置）
 */
package com.motu.monstercity.server.game.userdata;

import com.motu.vertx.module.utility.toolset.TimeUtils;
import com.motu.vertx.module.utility.toolset.Tool;
import io.vertx.core.json.JsonObject;

public class UserExtInfo extends UserExtInfoModel {
    public UserExtInfo() {
        super();
    }

    public JsonObject insert() {
        putResetTime(TimeUtils.getCurTime());
        return super.insert();
    }

    public void reset() {
        if (!TimeUtils.isToday(resetTime)) {
            putResetTime(TimeUtils.getCurTime());
            putDayIapBuy(0);
//            putBuddyChatUsers("");
            update();
        }
    }

    public void charge(int diamondCharge, int diamondFree, int vipscore, long chargeTime) {
        addDiamondCharge(diamondCharge);
        addDiamondFree(diamondFree);
        addIapBuy(vipscore);
        addDayIapBuy(vipscore);
        putChargeTime(chargeTime);
    }

    /**
     * 是否是首次充值
     */
    public boolean isFirstRecharge() {
        return getChargeTime() == 0;
    }

    /**
     * 获取当前是注册的第几天
     */
    public int getRegisterDay() {
        return TimeUtils.getDiffDay(getRegisterTime(), TimeUtils.getCurTime()) + 1;
    }


}
